package com.example.modeldemo.base;

import com.example.modeldemo.baseenum.ResultEnum;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * 返回信息包装类
 * @author lc
 */
@Data
@Accessors(chain = true)
public class Result {
    /**
     * 返回状态码 0 正常，-1 错误
     */
    Integer code;
    /**
     * 返回信息
     */
    String msg;
    /**
     * 返回数据
     */
    Object data;

    public static Result ok(Object obj){
        return new Result().setData(obj).setCode(ResultEnum.SUCCESS.getCode()).setMsg(ResultEnum.SUCCESS.getMsg());
    }

    public static Result failed(Object obj){
        return new Result().setData(obj).setCode(ResultEnum.ERROR.getCode()).setMsg(ResultEnum.ERROR.getMsg());
    }

}
